package com.lastproject.ejb.dao;

import java.util.List;

import javax.ejb.Remote;

import com.lastproject.dto.WaitingListDTO;
import com.lastproject.ejb.exceptions.NoPermissionException;

@Remote
public interface WaitingListDAORemote {

	void create(boolean hasPermission, WaitingListDTO entity)
			throws NoPermissionException;

	void edit(WaitingListDTO entity);

	void remove(WaitingListDTO entity);

	WaitingListDTO findById(Object id);

	public List<WaitingListDTO> getAll();

	/**
	 * Returns the waiting list for a certain book, given the book id.
	 * 
	 * @param id
	 *            the id of the book.
	 * @return the waiting list for the given book id.
	 */
	public List<WaitingListDTO> getByIdBook(int id);

	public List<WaitingListDTO> getByIdUserIdBook(int idb, int idu);

	/**
	 * Finds the users (others than the given one) that that have reserved or
	 * borrowed the given book.
	 * 
	 * @param bookId
	 *            the id of the book
	 * @param userId
	 *            the id of the current user
	 * @return true, if there are no user requests in the waiting list or no
	 *         user has borrowed the book, false, if otherwise.
	 */
	public boolean getByBookIdOtherUser(int bookId, int userId);

	void remove(int bookId, int userId);
}
